package Utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @BelongsProject: TS
 * @BelongsPackage: Utils
 * @Author: LiuJianDong
 * @CreateTime: 2025-01-21  16:16
 * @Description: TODO
 * @Version: 1.0
 */
public class StringHandlerUtils {
    //提取html文本中的纯文本
    public static   String stripHtmlTags(String html) {
        Pattern pattern = Pattern.compile("<[^>]*>");
        Matcher matcher = pattern.matcher(html);
        String strippedHtml = matcher.replaceAll("");
        // 去除特殊字符
        strippedHtml = strippedHtml.replaceAll("&nbsp;", "");
        strippedHtml = strippedHtml.replaceAll("&gt;", "");
        strippedHtml = strippedHtml.replaceAll("\\n", "");
        return strippedHtml;
    }
}
